package jd.jd2.dao;

import jd.jd2.Equip;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component("playerDao")
public class PlayerDaoImpl implements PlayerDao {

    /**
     * 升级装备
     *
     * @param e   原装备
     * @param map 在原装备上要升级的属性
     * @return
     */
    @Override
    public Equip updateEquip(Equip e, Map<String, String> map) {
        if("".equals(e.getType())){
            if (map.get("name")!=null) {
                e.setName(map.get("name")+e.getName());
            }
            if(map.get("attack")!=null){
                e.setAttackPlus(Long.parseLong(map.get("attack"))+e.getAttackPlus());
            }
            if(map.get("defence")!=null){
                e.setDefencePlus(Long.parseLong(map.get("defence"))+e.getDefencePlus());
            }
        }
        return e;
    }

}
